package com.efrei.schoolmanager.model.obj;

import java.io.Serializable;

import com.efrei.schoolmanager.exceptions.LogicException;
import com.efrei.schoolmanager.tools.Verifs;

public class Responsable implements Serializable {
	private static final long serialVersionUID = -7076774016990085467L;
	
	/** Attributes */
	private int responsableId;
	private String nom;
	private String prenom;
	private String rue;
	private Ville ville;
	private String telephoneFixe;
	private String telephoneMobile;
	private String telephoneProfessionnel;
	private String email;

	public Responsable() {
	}

	public Responsable(String nom, String prenom,
			String rue, Ville ville, String telephoneFixe,
			String telephoneMobile, String telephoneProfessionnel, String email) {
		super();
		this.nom = nom;
		this.prenom = prenom;
		this.rue = rue;
		this.ville = ville;
		this.telephoneFixe = telephoneFixe;
		this.telephoneMobile = telephoneMobile;
		this.telephoneProfessionnel = telephoneProfessionnel;
		this.email = email;
	}
	
	@Override
	public String toString() {
		String sep = " ";
		return new StringBuilder()
			.append(nom.toUpperCase())
			.append(sep).append(prenom)
			.toString();
	}

	public int getResponsableId() {
		return responsableId;
	}

	public void setResponsableId(int responsableId) {
		this.responsableId = responsableId;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		if(nom.length()==0)
			throw new IllegalArgumentException("nom vide !");
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		if(prenom.length()==0)
			throw new IllegalArgumentException("prenom vide !");
		this.prenom = prenom;
	}

	public String getRue() {
		return rue;
	}

	public void setRue(String rue) {
		this.rue = rue;
	}

	public Ville getVille() {
		return ville;
	}

	public void setVille(Ville ville) {
		this.ville = ville;
	}

	public String getTelephoneFixe() {
		return telephoneFixe;
	}

	public void setTelephoneFixe(String telephoneFixe) {
		this.telephoneFixe = telephoneFixe;
	}

	public String getTelephoneMobile() {
		return telephoneMobile;
	}

	public void setTelephoneMobile(String telephoneMobile) {
		this.telephoneMobile = telephoneMobile;
	}

	public String getTelephoneProfessionnel() {
		return telephoneProfessionnel;
	}

	public void setTelephoneProfessionnel(String telephoneProfessionnel) {
		this.telephoneProfessionnel = telephoneProfessionnel;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public static void check(String nom, String prenom,
			String rue, String telephoneFixe,
			String telephoneMobile, String telephoneProfessionnel, String email) throws LogicException {
		Verifs.checkString(nom, "nom invalide");
		Verifs.checkString(prenom, "prenom invalide");
		Verifs.checkString(rue, "rue invalide");
		Verifs.checkNullString(telephoneFixe, "telephone fix invalide");
		Verifs.checkNullString(telephoneMobile, "telephone mobile invalide");
		Verifs.checkNullString(telephoneProfessionnel, "telephone professionnel invalide");
		Verifs.checkNullString(email, "email invalide");
	}
}

